package aor2.cpu.blockoperation;

import aor2.components.Element;
import aor2.components.ElementIO;
import aor2.components.ElementIOException;
import aor2.cpu.InternBus;
import aor2.cpu.blockcontrol.ControlSignalSet;

public enum Gate implements ElementIO {
	G12(InternBus.M1, InternBus.M2), G21(InternBus.M2, InternBus.M1);

	static {
		ControlSignalSet css = ControlSignalSet.getInstance();
		css.get("G21").addSourceElementIO(G21);
		css.get("G12").addSourceElementIO(G12);
	}

	private Gate(Element src, Element dst) {
		this.src = src;
		this.dst = dst;
	}

	private Element src, dst;

	@Override
	public void in() throws ElementIOException {
		// ignore
	}

	@Override
	public void out() throws ElementIOException {
		// if(!(src!=null&&dst!=null))return;
		dst.setState(src.getState());
	}
}
